﻿using System;
using System.Data;
using System.Text;
using System.Data.SqlClient;
using MxWeiXinPF.DBUtility;
using System.Collections.Generic;
using MxWeiXinPF.Common;//Please add references
namespace MxWeiXinPF.DAL
{
	/// <summary>
	/// 数据访问类:wx_shop_product
	/// </summary>
    public partial class wx_shop_product
    {
        public int Add(MxWeiXinPF.Model.wx_shop_product model)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("insert into wx_shop_product(");
            builder.Append("wid,categoryId,brandId,sku,productName,shortDesc,unit,weight,description,seo_title,seo_keywords,seo_description,focusImgUrl,thumbnailsUrll,recommended,latest,hotsale,specialOffer,costPrice,marketPrice,salePrice,upselling,stock,addDate,vistiCounts,sort_id,productionDate,ExpiryEndDate,updateDate,catalogId,ShopID,spec,Validity,Factory,ZhunZi,SumQty,OneDayQty,isSendMessage ,[DrugNumber],[DrugAbbreviate],[extInt],[extInt1],[extstr],[extstr1],[extstr2],[isRx])");
            builder.Append(" values (");
            builder.Append("@wid,@categoryId,@brandId,@sku,@productName,@shortDesc,@unit,@weight,@description,@seo_title,@seo_keywords,@seo_description,@focusImgUrl,@thumbnailsUrll,@recommended,@latest,@hotsale,@specialOffer,@costPrice,@marketPrice,@salePrice,@upselling,@stock,@addDate,@vistiCounts,@sort_id,@productionDate,@ExpiryEndDate,@updateDate,@catalogId,@ShopID,@spec,@Validity,@Factory,@ZhunZi,@SumQty,@OneDayQty,@isSendMessage,@DrugNumber,@DrugAbbreviate,@extInt,@extInt1,@extstr,@extstr1,@extstr2,@isRx)");
            builder.Append(";set @ReturnValue= @@IDENTITY");
            SqlParameter[] para = new SqlParameter[] { 
                new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@categoryId", SqlDbType.Int, 4), new SqlParameter("@brandId", SqlDbType.Int, 4), new SqlParameter("@sku", SqlDbType.VarChar, 20), new SqlParameter("@productName", SqlDbType.VarChar, 500), new SqlParameter("@shortDesc", SqlDbType.VarChar, 500), new SqlParameter("@unit", SqlDbType.VarChar, 10), new SqlParameter("@weight", SqlDbType.Float, 8), new SqlParameter("@description", SqlDbType.VarChar, 0x7d0), new SqlParameter("@seo_title", SqlDbType.VarChar, 200), new SqlParameter("@seo_keywords", SqlDbType.VarChar, 300), new SqlParameter("@seo_description", SqlDbType.VarChar, 500), new SqlParameter("@focusImgUrl", SqlDbType.VarChar, 800), new SqlParameter("@thumbnailsUrll", SqlDbType.VarChar, 800), new SqlParameter("@recommended", SqlDbType.Bit, 1), new SqlParameter("@latest", SqlDbType.Bit, 1), 
                new SqlParameter("@hotsale", SqlDbType.Bit, 1), new SqlParameter("@specialOffer", SqlDbType.Bit, 1), new SqlParameter("@costPrice", SqlDbType.Float, 8), new SqlParameter("@marketPrice", SqlDbType.Float, 8), new SqlParameter("@salePrice", SqlDbType.Float, 8), new SqlParameter("@upselling", SqlDbType.Bit, 1), new SqlParameter("@stock", SqlDbType.Int, 4), new SqlParameter("@addDate", SqlDbType.DateTime), new SqlParameter("@vistiCounts", SqlDbType.Int, 4), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@productionDate", SqlDbType.DateTime), new SqlParameter("@ExpiryEndDate", SqlDbType.DateTime), new SqlParameter("@updateDate", SqlDbType.DateTime), new SqlParameter("@catalogId", SqlDbType.Int, 4), new SqlParameter("@ShopID", SqlDbType.Int, 4), new SqlParameter("@spec", SqlDbType.VarChar, 100), 
                new SqlParameter("@Validity", SqlDbType.VarChar, 100), new SqlParameter("@Factory", SqlDbType.VarChar, 100), new SqlParameter("@ZhunZi", SqlDbType.VarChar, 100), new SqlParameter("@SumQty", SqlDbType.Int, 4), new SqlParameter("@OneDayQty", SqlDbType.Int, 4), new SqlParameter("@isSendMessage", SqlDbType.Bit, 1), new SqlParameter("@DrugNumber", SqlDbType.VarChar, 100), new SqlParameter("@DrugAbbreviate", SqlDbType.VarChar, 200), new SqlParameter("@extInt", SqlDbType.Int, 4), new SqlParameter("@extInt1", SqlDbType.Int, 4), new SqlParameter("@extstr", SqlDbType.VarChar, 100), new SqlParameter("@extstr1", SqlDbType.VarChar, 200), new SqlParameter("@extstr2", SqlDbType.VarChar, 500), new SqlParameter("@isRx", SqlDbType.VarChar, 10), new SqlParameter("@ReturnValue", SqlDbType.Int)
             };
            para[0].Value = model.wid;
            para[1].Value = model.categoryId;
            para[2].Value = model.brandId;
            para[3].Value = model.sku;
            para[4].Value = model.productName;
            para[5].Value = model.shortDesc;
            para[6].Value = model.unit;
            para[7].Value = model.weight;
            para[8].Value = model.description;
            para[9].Value = model.seo_title;
            para[10].Value = model.seo_keywords;
            para[11].Value = model.seo_description;
            para[12].Value = model.focusImgUrl;
            para[13].Value = model.thumbnailsUrll;
            para[14].Value = model.recommended;
            para[15].Value = model.latest;
            para[0x10].Value = model.hotsale;
            para[0x11].Value = model.specialOffer;
            para[0x12].Value = model.costPrice;
            para[0x13].Value = model.marketPrice;
            para[20].Value = model.salePrice;
            para[0x15].Value = model.upselling;
            para[0x16].Value = model.stock;
            para[0x17].Value = model.addDate;
            para[0x18].Value = model.vistiCounts;
            para[0x19].Value = model.sort_id;
            para[0x1a].Value = model.productionDate;
            para[0x1b].Value = model.ExpiryEndDate;
            para[0x1c].Value = model.updateDate;
            para[0x1d].Value = model.catalogId;
            para[30].Value = model.shopid;
            para[0x1f].Value = model.spec;
            para[0x20].Value = model.validity;
            para[0x21].Value = model.factory;
            para[0x22].Value = model.zhunzi;
            para[0x23].Value = model.sumqty;
            para[0x24].Value = model.onedayqty;
            para[0x25].Value = model.issendmessage;
            para[0x26].Value = model.drugnumber;
            para[0x27].Value = model.drugabbreviate;
            para[40].Value = model.extInt;
            para[0x29].Value = model.extInt1;
            para[0x2a].Value = model.extstr;
            para[0x2b].Value = model.extstr1;
            para[0x2c].Value = model.extstr2;
            para[0x2d].Value = model.isRx;
            para[0x2e].Direction = ParameterDirection.Output;
            List<CommandInfo> sQLStringList = new List<CommandInfo>();
            CommandInfo item = new CommandInfo(builder.ToString(), para);
            sQLStringList.Add(item);
            if (model.albums != null)
            {
                foreach (MxWeiXinPF.Model.wx_shop_albums _albums in model.albums)
                {
                    StringBuilder builder2 = new StringBuilder();
                    builder2.Append("insert into  wx_shop_albums(");
                    builder2.Append("productId,thumb_path,original_path,remark,isdefault)");
                    builder2.Append(" values (");
                    builder2.Append("@productId,@thumb_path,@original_path,@remark,@isdefault)");
                    SqlParameter[] parameterArray2 = new SqlParameter[] { new SqlParameter("@productId", SqlDbType.Int, 4), new SqlParameter("@thumb_path", SqlDbType.NVarChar, 0xff), new SqlParameter("@original_path", SqlDbType.NVarChar, 0xff), new SqlParameter("@remark", SqlDbType.NVarChar, 500), new SqlParameter("@isdefault", SqlDbType.VarChar, 10) };
                    parameterArray2[0].Direction = ParameterDirection.InputOutput;
                    parameterArray2[1].Value = _albums.thumb_path;
                    parameterArray2[2].Value = _albums.original_path;
                    parameterArray2[3].Value = _albums.remark;
                    parameterArray2[4].Value = _albums.isdefault;
                    item = new CommandInfo(builder2.ToString(), parameterArray2);
                    sQLStringList.Add(item);
                }
            }
            if (model.attrs != null)
            {
                foreach (MxWeiXinPF.Model.wx_shop_productAttr_value _value in model.attrs)
                {
                    StringBuilder builder3 = new StringBuilder();
                    builder3.Append("insert into  wx_shop_productAttr_value(");
                    builder3.Append("productId,attributeId,paValue)");
                    builder3.Append(" values (");
                    builder3.Append("@productId,@attributeId,@paValue)");
                    SqlParameter[] parameterArray3 = new SqlParameter[] { new SqlParameter("@productId", SqlDbType.Int, 4), new SqlParameter("@attributeId", SqlDbType.Int, 4), new SqlParameter("@paValue", SqlDbType.NVarChar, 300) };
                    parameterArray3[0].Direction = ParameterDirection.InputOutput;
                    parameterArray3[1].Value = _value.attributeId;
                    parameterArray3[2].Value = _value.paValue;
                    item = new CommandInfo(builder3.ToString(), parameterArray3);
                    sQLStringList.Add(item);
                }
            }
            if (model.skulist != null)
            {
                foreach (MxWeiXinPF.Model.wx_shop_sku _sku in model.skulist)
                {
                    StringBuilder builder4 = new StringBuilder();
                    builder4.Append("insert into  wx_shop_sku(");
                    builder4.Append("productId,attributeId,attributeValue,price)");
                    builder4.Append(" values (");
                    builder4.Append("@productId,@attributeId,@attributeValue,@price)");
                    SqlParameter[] parameterArray4 = new SqlParameter[] { new SqlParameter("@productId", SqlDbType.Int, 4), new SqlParameter("@attributeId", SqlDbType.Int, 4), new SqlParameter("@attributeValue", SqlDbType.NVarChar, 300), new SqlParameter("@price", SqlDbType.Float, 10) };
                    parameterArray4[0].Direction = ParameterDirection.InputOutput;
                    parameterArray4[1].Value = _sku.attributeId;
                    parameterArray4[2].Value = _sku.attributeValue;
                    parameterArray4[3].Value = _sku.price;
                    item = new CommandInfo(builder4.ToString(), parameterArray4);
                    sQLStringList.Add(item);
                }
            }
            DbHelperSQL.ExecuteSqlTranWithIndentity(sQLStringList);
            return (int)para[0x2e].Value;
        }

        public MxWeiXinPF.Model.wx_shop_product DataRowToModel(DataRow row)
        {
            MxWeiXinPF.Model.wx_shop_product _product = new MxWeiXinPF.Model.wx_shop_product();
            if (row != null)
            {
                if ((row["id"] != null) && (row["id"].ToString() != ""))
                {
                    _product.id = int.Parse(row["id"].ToString());
                }
                if ((row["wid"] != null) && (row["wid"].ToString() != ""))
                {
                    _product.wid = new int?(int.Parse(row["wid"].ToString()));
                }
                if ((row["categoryId"] != null) && (row["categoryId"].ToString() != ""))
                {
                    _product.categoryId = new int?(int.Parse(row["categoryId"].ToString()));
                }
                if ((row["brandId"] != null) && (row["brandId"].ToString() != ""))
                {
                    _product.brandId = new int?(int.Parse(row["brandId"].ToString()));
                }
                if (row["sku"] != null)
                {
                    _product.sku = row["sku"].ToString();
                }
                if (row["productName"] != null)
                {
                    _product.productName = row["productName"].ToString();
                }
                if (row["shortDesc"] != null)
                {
                    _product.shortDesc = row["shortDesc"].ToString();
                }
                if (row["unit"] != null)
                {
                    _product.unit = row["unit"].ToString();
                }
                if ((row["weight"] != null) && (row["weight"].ToString() != ""))
                {
                    _product.weight = new decimal?(decimal.Parse(row["weight"].ToString()));
                }
                if (row["description"] != null)
                {
                    _product.description = row["description"].ToString();
                }
                if (row["seo_title"] != null)
                {
                    _product.seo_title = row["seo_title"].ToString();
                }
                if (row["seo_keywords"] != null)
                {
                    _product.seo_keywords = row["seo_keywords"].ToString();
                }
                if (row["seo_description"] != null)
                {
                    _product.seo_description = row["seo_description"].ToString();
                }
                if (row["focusImgUrl"] != null)
                {
                    _product.focusImgUrl = row["focusImgUrl"].ToString();
                }
                if (row["thumbnailsUrll"] != null)
                {
                    _product.thumbnailsUrll = row["thumbnailsUrll"].ToString();
                }
                if ((row["recommended"] != null) && (row["recommended"].ToString() != ""))
                {
                    if ((row["recommended"].ToString() == "1") || (row["recommended"].ToString().ToLower() == "true"))
                    {
                        _product.recommended = true;
                    }
                    else
                    {
                        _product.recommended = false;
                    }
                }
                if ((row["latest"] != null) && (row["latest"].ToString() != ""))
                {
                    if ((row["latest"].ToString() == "1") || (row["latest"].ToString().ToLower() == "true"))
                    {
                        _product.latest = true;
                    }
                    else
                    {
                        _product.latest = false;
                    }
                }
                if ((row["hotsale"] != null) && (row["hotsale"].ToString() != ""))
                {
                    if ((row["hotsale"].ToString() == "1") || (row["hotsale"].ToString().ToLower() == "true"))
                    {
                        _product.hotsale = true;
                    }
                    else
                    {
                        _product.hotsale = false;
                    }
                }
                if ((row["specialOffer"] != null) && (row["specialOffer"].ToString() != ""))
                {
                    if ((row["specialOffer"].ToString() == "1") || (row["specialOffer"].ToString().ToLower() == "true"))
                    {
                        _product.specialOffer = true;
                    }
                    else
                    {
                        _product.specialOffer = false;
                    }
                }
                if ((row["costPrice"] != null) && (row["costPrice"].ToString() != ""))
                {
                    _product.costPrice = new decimal?(decimal.Parse(row["costPrice"].ToString()));
                }
                if ((row["marketPrice"] != null) && (row["marketPrice"].ToString() != ""))
                {
                    _product.marketPrice = new decimal?(decimal.Parse(row["marketPrice"].ToString()));
                }
                if ((row["salePrice"] != null) && (row["salePrice"].ToString() != ""))
                {
                    _product.salePrice = new decimal?(decimal.Parse(row["salePrice"].ToString()));
                }
                if ((row["upselling"] != null) && (row["upselling"].ToString() != ""))
                {
                    if ((row["upselling"].ToString() == "1") || (row["upselling"].ToString().ToLower() == "true"))
                    {
                        _product.upselling = true;
                    }
                    else
                    {
                        _product.upselling = false;
                    }
                }
                if ((row["stock"] != null) && (row["stock"].ToString() != ""))
                {
                    _product.stock = new int?(int.Parse(row["stock"].ToString()));
                }
                if ((row["addDate"] != null) && (row["addDate"].ToString() != ""))
                {
                    _product.addDate = new DateTime?(DateTime.Parse(row["addDate"].ToString()));
                }
                if ((row["vistiCounts"] != null) && (row["vistiCounts"].ToString() != ""))
                {
                    _product.vistiCounts = new int?(int.Parse(row["vistiCounts"].ToString()));
                }
                if ((row["sort_id"] != null) && (row["sort_id"].ToString() != ""))
                {
                    _product.sort_id = new int?(int.Parse(row["sort_id"].ToString()));
                }
                if ((row["productionDate"] != null) && (row["productionDate"].ToString() != ""))
                {
                    _product.productionDate = new DateTime?(DateTime.Parse(row["productionDate"].ToString()));
                }
                if ((row["ExpiryEndDate"] != null) && (row["ExpiryEndDate"].ToString() != ""))
                {
                    _product.ExpiryEndDate = new DateTime?(DateTime.Parse(row["ExpiryEndDate"].ToString()));
                }
                if ((row["updateDate"] != null) && (row["updateDate"].ToString() != ""))
                {
                    _product.updateDate = new DateTime?(DateTime.Parse(row["updateDate"].ToString()));
                }
                if ((row["catalogId"] != null) && (row["catalogId"].ToString() != ""))
                {
                    _product.catalogId = int.Parse(row["catalogId"].ToString());
                }
                if ((row["shopid"] != null) && (row["shopid"].ToString() != ""))
                {
                    _product.shopid = int.Parse(row["shopid"].ToString());
                }
                if (row["spec"] != null)
                {
                    _product.spec = row["spec"].ToString();
                }
                if (row["validity"] != null)
                {
                    _product.validity = row["validity"].ToString();
                }
                if (row["factory"] != null)
                {
                    _product.factory = row["factory"].ToString();
                }
                if (row["zhunzi"] != null)
                {
                    _product.zhunzi = row["zhunzi"].ToString();
                }
                if ((row["sumqty"] != null) && (row["sumqty"].ToString() != ""))
                {
                    _product.sumqty = int.Parse(row["sumqty"].ToString());
                }
                if ((row["onedayqty"] != null) && (row["onedayqty"].ToString() != ""))
                {
                    _product.onedayqty = int.Parse(row["onedayqty"].ToString());
                }
                if ((row["issendmessage"] != null) && (row["issendmessage"].ToString() != ""))
                {
                    if ((row["issendmessage"].ToString() == "1") || (row["issendmessage"].ToString().ToLower() == "true"))
                    {
                        _product.issendmessage = true;
                    }
                    else
                    {
                        _product.issendmessage = false;
                    }
                }
                if ((row["extInt"] != null) && (row["extInt"].ToString() != ""))
                {
                    _product.extInt = int.Parse(row["extInt"].ToString());
                }
                if ((row["extInt1"] != null) && (row["extInt1"].ToString() != ""))
                {
                    _product.extInt1 = int.Parse(row["extInt1"].ToString());
                }
                if (row["extstr"] != null)
                {
                    _product.extstr1 = row["extstr"].ToString();
                }
                if (row["extstr1"] != null)
                {
                    _product.extstr1 = row["extstr1"].ToString();
                }
                if (row["extstr2"] != null)
                {
                    _product.extstr2 = row["extstr2"].ToString();
                }
                if (row["drugnumber"] != null)
                {
                    _product.drugnumber = row["drugnumber"].ToString();
                }
                if ((row["isRx"] == null) || !(row["isRx"].ToString() != ""))
                {
                    return _product;
                }
                if ((row["isRx"].ToString() == "1") || (row["isRx"].ToString().ToLower() == "true"))
                {
                    _product.isRx = true;
                    return _product;
                }
                _product.isRx = false;
            }
            return _product;
        }

        public bool Delete(int id)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("delete from wx_shop_productAttr_value ");
            builder.Append(" where productId=@productId ");
            SqlParameter[] para = new SqlParameter[] { new SqlParameter("@productId", SqlDbType.Int, 4) };
            para[0].Value = id;
            List<CommandInfo> cmdList = new List<CommandInfo>();
            CommandInfo item = new CommandInfo(builder.ToString(), para);
            cmdList.Add(item);
            StringBuilder builder2 = new StringBuilder();
            builder2.Append("delete from wx_shop_sku ");
            builder2.Append(" where productId=@productId ");
            SqlParameter[] parameterArray2 = new SqlParameter[] { new SqlParameter("@productId", SqlDbType.Int, 4) };
            parameterArray2[0].Value = id;
            item = new CommandInfo(builder2.ToString(), parameterArray2);
            cmdList.Add(item);
            StringBuilder builder3 = new StringBuilder();
            builder3.Append("delete from wx_shop_albums ");
            builder3.Append(" where productId=@productId ");
            SqlParameter[] parameterArray3 = new SqlParameter[] { new SqlParameter("@productId", SqlDbType.Int, 4) };
            parameterArray3[0].Value = id;
            item = new CommandInfo(builder3.ToString(), parameterArray3);
            cmdList.Add(item);
            StringBuilder builder4 = new StringBuilder();
            builder4.Append("delete from wx_shop_comment ");
            builder4.Append(" where productId=@productId ");
            SqlParameter[] parameterArray4 = new SqlParameter[] { new SqlParameter("@productId", SqlDbType.Int, 4) };
            parameterArray4[0].Value = id;
            item = new CommandInfo(builder4.ToString(), parameterArray4);
            cmdList.Add(item);
            StringBuilder builder5 = new StringBuilder();
            builder5.Append("delete from wx_shop_cart ");
            builder5.Append(" where productId=@productId ");
            SqlParameter[] parameterArray5 = new SqlParameter[] { new SqlParameter("@productId", SqlDbType.Int, 4) };
            parameterArray5[0].Value = id;
            item = new CommandInfo(builder5.ToString(), parameterArray5);
            cmdList.Add(item);
            StringBuilder builder6 = new StringBuilder();
            builder6.Append("delete from wx_shop_product ");
            builder6.Append(" where id=@id");
            SqlParameter[] parameterArray6 = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int, 4) };
            parameterArray6[0].Value = id;
            item = new CommandInfo(builder6.ToString(), parameterArray6);
            cmdList.Add(item);
            return (DbHelperSQL.ExecuteSqlTran(cmdList) > 0);
        }

        public bool DeleteList(string idlist)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("delete from wx_shop_product ");
            builder.Append(" where id in (" + idlist + ")  ");
            return (DbHelperSQL.ExecuteSql(builder.ToString()) > 0);
        }

        public bool Exists(int id)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("select count(1) from wx_shop_product");
            builder.Append(" where id=@id");
            SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int, 4) };
            cmdParms[0].Value = id;
            return DbHelperSQL.Exists(builder.ToString(), cmdParms);
        }

        public DataSet GetList(string strWhere)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("select a.id,a.wid,a.categoryId,b.title,brandId,sku,productName,shortDesc,unit,weight,description,a.seo_title,a.seo_keywords,a.seo_description,focusImgUrl,thumbnailsUrll,recommended,latest,hotsale,specialOffer,costPrice,marketPrice,salePrice,upselling,stock,addDate,vistiCounts,a.sort_id,productionDate,ExpiryEndDate,updateDate,catalogId,ShopID,spec,Validity,Factory,ZhunZi,SumQty,OneDayQty,isSendMessage ,DrugNumber,[DrugAbbreviate],[extInt],[extInt1],[extstr],[extstr1],[extstr2],[isRx] ");
            builder.Append(" FROM wx_shop_product a left join wx_shop_category b on a.categoryId=b.id ");
            if (strWhere.Trim() != "")
            {
                builder.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(builder.ToString());
        }

        public DataSet GetList(int Top, string strWhere, string filedOrder)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("select ");
            if (Top > 0)
            {
                builder.Append(" top " + Top.ToString());
            }
            builder.Append(" id,wid,categoryId,brandId,sku,productName,shortDesc,unit,weight,description,seo_title,seo_keywords,seo_description,focusImgUrl,thumbnailsUrll,recommended,latest,hotsale,specialOffer,costPrice,marketPrice,salePrice,upselling,stock,addDate,vistiCounts,sort_id,productionDate,ExpiryEndDate,updateDate,catalogId,ShopID,spec,Validity,Factory,ZhunZi,SumQty,OneDayQty,isSendMessage ,[DrugNumber],[DrugAbbreviate],[extInt],[extInt1],[extstr],[extstr1],[extstr2],[isRx]");
            builder.Append(" FROM wx_shop_product ");
            if (strWhere.Trim() != "")
            {
                builder.Append(" where " + strWhere);
            }
            builder.Append(" order by " + filedOrder);
            return DbHelperSQL.Query(builder.ToString());
        }

        public DataSet GetList(int wid, int category_id, int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(" select  link_url='',(select top 1 original_path from dbo.wx_shop_albums where  productId=p.id and isdefault='1') as productpic,(select title from dbo.wx_shop_category where  id=p.categoryId) as title,p.*,a.real_name as companyname,a.telephone as companymobile from wx_shop_product p ");
            builder.Append(" left join dt_manager a  on p.shopid=a.id ");
            builder.Append(" where  shopid=" + wid);
            if (category_id > 0)
            {
                builder.Append(" and categoryId in(select id from  wx_shop_category where class_list like '%," + category_id + ",%')");
            }
            if (strWhere.Trim() != "")
            {
                builder.Append(" and  " + strWhere);
            }
            recordCount = Convert.ToInt32(DbHelperSQL.GetSingle(PagingHelper.CreateCountingSql(builder.ToString())));
            return DbHelperSQL.Query(PagingHelper.CreatePagingSql(recordCount, pageSize, pageIndex, builder.ToString(), filedOrder));
        }
        public DataSet GetListEx(int category_id, int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(" select  link_url='',(select top 1 original_path from dbo.wx_shop_albums where  productId=p.id and isdefault='1') as productpic,(select title from dbo.wx_shop_category where  id=p.categoryId) as title,p.*,a.real_name as companyname,a.telephone as companymobile from wx_shop_product p ");
            builder.Append(" left join dt_manager a  on p.shopid=a.id ");
            builder.Append(" where  ");
            if (category_id > 0)
            {
                builder.Append(" categoryId in(select id from  wx_shop_category where class_list like '%," + category_id + ",%')");
                if (strWhere.Trim() != "")
                {
                    builder.Append("  and " + strWhere);
                }
            }
            else {
                if (strWhere.Trim() != "")
                {
                    builder.Append("  " + strWhere);
                }
            }
            recordCount = Convert.ToInt32(DbHelperSQL.GetSingle(PagingHelper.CreateCountingSql(builder.ToString())));
            return DbHelperSQL.Query(PagingHelper.CreatePagingSql(recordCount, pageSize, pageIndex, builder.ToString(), filedOrder));
        }
        public DataSet GetList(int wid, int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(" select  link_url='',(select top 1 original_path from dbo.wx_shop_albums where  productId=p.id and isdefault='1') as productpic,(select title from dbo.wx_shop_category where  id=p.categoryId) as title,p.*,a.real_name as companyname,a.telephone as companymobile from wx_shop_product p ");
            builder.Append(" left join dt_manager a  on p.shopid=a.id ");
            builder.Append(" where  wid=" + wid);
            //if (category_id > 0)
            //{
            //    builder.Append(" and categoryId in(select id from  wx_shop_category where class_list like '%," + category_id + ",%')");
            //}
            //builder.Append(" and categoryId in(select id from  wx_shop_category where shopid=" + wid + ")");
            if (strWhere.Trim() != "")
            {
                builder.Append(" and  " + strWhere);
            }
            recordCount = Convert.ToInt32(DbHelperSQL.GetSingle(PagingHelper.CreateCountingSql(builder.ToString())));
            return DbHelperSQL.Query(PagingHelper.CreatePagingSql(recordCount, pageSize, pageIndex, builder.ToString(), filedOrder));
        }

        public DataSet GetList(int wid, string keyword, int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(" select  link_url='',(select top 1 original_path from dbo.wx_shop_albums where  productId=p.id and isdefault='1') as productpic,* from wx_shop_product p ");
            builder.Append(" where  wid=" + wid);
            if (!keyword.Equals(""))
            {
                builder.Append(" and (isnull(productname,'')  like '%" + keyword + "%'  or isnull(pycode,'')  like '%" + keyword + "%' or isnull(sku,'')  like '%" + keyword + "%' )");
            }
            if (strWhere.Trim() != "")
            {
                builder.Append(" and  " + strWhere);
            }
            recordCount = Convert.ToInt32(DbHelperSQL.GetSingle(PagingHelper.CreateCountingSql(builder.ToString())));
            return DbHelperSQL.Query(PagingHelper.CreatePagingSql(recordCount, pageSize, pageIndex, builder.ToString(), filedOrder));
        }

        public DataSet GetList(int top, int wid, int category_id, int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("select ");
            if (top > 0)
            {
                builder.Append(" top " + top.ToString());
            }
            builder.Append("  link_url='',(select top 1 original_path from dbo.wx_shop_albums where  productId=p.id and isdefault='1') as productpic,p.*,a.real_name as companyname,a.telephone as companymobile from wx_shop_product p ");
            builder.Append(" left join dt_manager a  on p.shopid=a.id ");
            builder.Append(" where  wid=" + wid);
            if (category_id > 0)
            {
                builder.Append(" and categoryId in(select id from  wx_shop_category where class_list like '%," + category_id + ",%')");
            }
            if (strWhere.Trim() != "")
            {
                builder.Append(" and  " + strWhere);
            }
            recordCount = Convert.ToInt32(DbHelperSQL.GetSingle(PagingHelper.CreateCountingSql(builder.ToString())));
            return DbHelperSQL.Query(PagingHelper.CreatePagingSql(recordCount, pageSize, pageIndex, builder.ToString(), filedOrder));
        }

        public DataSet GetListByPage(string strWhere, string orderby, int startIndex, int endIndex)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("SELECT * FROM ( ");
            builder.Append(" SELECT ROW_NUMBER() OVER (");
            if (!string.IsNullOrEmpty(orderby.Trim()))
            {
                builder.Append("order by T." + orderby);
            }
            else
            {
                builder.Append("order by T.id desc");
            }
            builder.Append(")AS Row, T.*  from wx_shop_product T ");
            if (!string.IsNullOrEmpty(strWhere.Trim()))
            {
                builder.Append(" WHERE " + strWhere);
            }
            builder.Append(" ) TT");
            builder.AppendFormat(" WHERE TT.Row between {0} and {1}", startIndex, endIndex);
            return DbHelperSQL.Query(builder.ToString());
        }

        public DataSet GetListForImport(string strWhere)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("select a.id,categoryId,b.title,sku,productName,spec,Validity,Factory,costPrice,marketPrice,salePrice,ZhunZi,stock");
            builder.Append(" FROM wx_shop_product a left join wx_shop_category b on a.categoryId=b.id ");
            if (strWhere.Trim() != "")
            {
                builder.Append(" where " + strWhere);
            }
            return DbHelperSQL.Query(builder.ToString());
        }

        public DataSet GetListForStock(int wid, int category_id, int pageSize, int pageIndex, string strWhere, string filedOrder, out int recordCount)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(" select  link_url='',(select top 1 original_path from dbo.wx_shop_albums where  productId=p.id and isdefault='1') as productpic,(select title from dbo.wx_shop_category where  id=p.categoryId) as title,p.*,a.real_name as companyname,a.telephone as companymobile from wx_shop_product p ");
            builder.Append(" left join dt_manager a  on p.shopid=a.id ");
            builder.Append(" where stock>0 ");
            if (category_id > 0)
            {
                builder.Append(" and categoryId in(select id from  wx_shop_category where class_list like '%," + category_id + ",%')");
            }
            if (strWhere.Trim() != "")
            {
                builder.Append(" and  " + strWhere);
            }
            recordCount = Convert.ToInt32(DbHelperSQL.GetSingle(PagingHelper.CreateCountingSql(builder.ToString())));
            return DbHelperSQL.Query(PagingHelper.CreatePagingSql(recordCount, pageSize, pageIndex, builder.ToString(), filedOrder));
        }

        public int GetMaxId()
        {
            return DbHelperSQL.GetMaxID("id", "wx_shop_product");
        }

        public int GetMaxIDByCode(string code)
        {
            return DbHelperSQL.GetMaxIDByCode("id", "wx_shop_product", "sku='" + code + "'", " order by id desc");
        }

        public MxWeiXinPF.Model.wx_shop_product GetModel(int id)
        {
            MxWeiXinPF.Model.wx_shop_product _product = new MxWeiXinPF.Model.wx_shop_product();
            StringBuilder builder = new StringBuilder();
            builder.Append("select  top 1 id,wid,categoryId,brandId,sku,productName,shortDesc,unit,weight,description,seo_title,seo_keywords,seo_description,focusImgUrl,thumbnailsUrll,recommended,latest,hotsale,specialOffer,costPrice,marketPrice,salePrice,upselling,stock,addDate,vistiCounts,sort_id,productionDate,ExpiryEndDate,updateDate,catalogId,ShopID,spec,Validity,Factory,ZhunZi,SumQty,OneDayQty,isSendMessage ,[DrugNumber],[DrugAbbreviate],[extInt],[extInt1],[extstr],[extstr1],[extstr2],[isRx] from wx_shop_product ");
            builder.Append(" where id=@id");
            SqlParameter[] cmdParms = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int, 4) };
            cmdParms[0].Value = id;
            MxWeiXinPF.Model.wx_shop_product _product2 = new MxWeiXinPF.Model.wx_shop_product();
            DataSet set = DbHelperSQL.Query(builder.ToString(), cmdParms);
            if (set.Tables[0].Rows.Count > 0)
            {
                _product = this.DataRowToModel(set.Tables[0].Rows[0]);
            }
            return _product;
        }

        public DataSet getProductNumber(int wid)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(string.Concat(new object[] { " select (select count(*) from wx_shop_product where wid=", wid, ") as totalproduct,(select count(*) from  wx_shop_product where wid=", wid, " and updateDate>getdate()-45) as newproduct " }));
            return DbHelperSQL.Query(builder.ToString());
        }

        public DataSet getProductNumberbyShopID(int wid, int shopid)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append(string.Concat(new object[] { " select (select count(*) from wx_shop_product where wid=", wid, " and shopid=", shopid, " and upselling='1') as totalproduct,(select count(*) from  wx_shop_product where wid=", wid, " and shopid=", shopid, " and updateDate>getdate()-45 and upselling='1') as newproduct " }));
            return DbHelperSQL.Query(builder.ToString());
        }

        public int GetRecordCount(string strWhere)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("select count(1) FROM wx_shop_product ");
            if (strWhere.Trim() != "")
            {
                builder.Append(" where " + strWhere);
            }
            object single = DbHelperSQL.GetSingle(builder.ToString());
            if (single == null)
            {
                return 0;
            }
            return Convert.ToInt32(single);
        }

        public bool Update(MxWeiXinPF.Model.wx_shop_product model)
        {
            using (SqlConnection connection = new SqlConnection(DbHelperSQL.connectionString))
            {
                connection.Open();
                using (SqlTransaction transaction = connection.BeginTransaction())
                {
                    try
                    {
                        StringBuilder builder = new StringBuilder();
                        builder.Append("update wx_shop_product set ");
                        builder.Append("wid=@wid,");
                        builder.Append("categoryId=@categoryId,");
                        builder.Append("brandId=@brandId,");
                        builder.Append("sku=@sku,");
                        builder.Append("productName=@productName,");
                        builder.Append("shortDesc=@shortDesc,");
                        builder.Append("unit=@unit,");
                        builder.Append("weight=@weight,");
                        builder.Append("description=@description,");
                        builder.Append("seo_title=@seo_title,");
                        builder.Append("seo_keywords=@seo_keywords,");
                        builder.Append("seo_description=@seo_description,");
                        builder.Append("focusImgUrl=@focusImgUrl,");
                        builder.Append("thumbnailsUrll=@thumbnailsUrll,");
                        builder.Append("recommended=@recommended,");
                        builder.Append("latest=@latest,");
                        builder.Append("hotsale=@hotsale,");
                        builder.Append("specialOffer=@specialOffer,");
                        builder.Append("costPrice=@costPrice,");
                        builder.Append("marketPrice=@marketPrice,");
                        builder.Append("salePrice=@salePrice,");
                        builder.Append("upselling=@upselling,");
                        builder.Append("stock=@stock,");
                        builder.Append("addDate=@addDate,");
                        builder.Append("vistiCounts=@vistiCounts,");
                        builder.Append("sort_id=@sort_id,");
                        builder.Append("productionDate=@productionDate,");
                        builder.Append("ExpiryEndDate=@ExpiryEndDate,");
                        builder.Append("updateDate=@updateDate,");
                        builder.Append("catalogId=@catalogId,");
                        builder.Append("ShopID=@ShopID,");
                        builder.Append("spec=@spec,");
                        builder.Append("Validity=@Validity,");
                        builder.Append("Factory=@Factory,");
                        builder.Append("ZhunZi=@ZhunZi,");
                        builder.Append("SumQty=@SumQty,");
                        builder.Append("OneDayQty=@OneDayQty,");
                        builder.Append("isSendMessage=@isSendMessage,");
                        builder.Append("DrugNumber=@DrugNumber,");
                        builder.Append("DrugAbbreviate=@DrugAbbreviate,");
                        builder.Append("extInt=@extInt,");
                        builder.Append("extInt1=@extInt1,");
                        builder.Append("extstr=@extstr,");
                        builder.Append("extstr1=@extstr1,");
                        builder.Append("extstr2=@extstr2, ");
                        builder.Append("isRx=@isRx");
                        builder.Append(" where id=@id");
                        SqlParameter[] cmdParms = new SqlParameter[] { 
                            new SqlParameter("@wid", SqlDbType.Int, 4), new SqlParameter("@categoryId", SqlDbType.Int, 4), new SqlParameter("@brandId", SqlDbType.Int, 4), new SqlParameter("@sku", SqlDbType.VarChar, 20), new SqlParameter("@productName", SqlDbType.VarChar, 500), new SqlParameter("@shortDesc", SqlDbType.VarChar, 500), new SqlParameter("@unit", SqlDbType.VarChar, 10), new SqlParameter("@weight", SqlDbType.Float, 8), new SqlParameter("@description", SqlDbType.VarChar, 0x7d0), new SqlParameter("@seo_title", SqlDbType.VarChar, 200), new SqlParameter("@seo_keywords", SqlDbType.VarChar, 300), new SqlParameter("@seo_description", SqlDbType.VarChar, 500), new SqlParameter("@focusImgUrl", SqlDbType.VarChar, 800), new SqlParameter("@thumbnailsUrll", SqlDbType.VarChar, 800), new SqlParameter("@recommended", SqlDbType.Bit, 1), new SqlParameter("@latest", SqlDbType.Bit, 1), 
                            new SqlParameter("@hotsale", SqlDbType.Bit, 1), new SqlParameter("@specialOffer", SqlDbType.Bit, 1), new SqlParameter("@costPrice", SqlDbType.Float, 8), new SqlParameter("@marketPrice", SqlDbType.Float, 8), new SqlParameter("@salePrice", SqlDbType.Float, 8), new SqlParameter("@upselling", SqlDbType.Bit, 1), new SqlParameter("@stock", SqlDbType.Int, 4), new SqlParameter("@addDate", SqlDbType.DateTime), new SqlParameter("@vistiCounts", SqlDbType.Int, 4), new SqlParameter("@sort_id", SqlDbType.Int, 4), new SqlParameter("@productionDate", SqlDbType.DateTime), new SqlParameter("@ExpiryEndDate", SqlDbType.DateTime), new SqlParameter("@updateDate", SqlDbType.DateTime), new SqlParameter("@catalogId", SqlDbType.Int, 4), new SqlParameter("@ShopID", SqlDbType.Int, 4), new SqlParameter("@spec", SqlDbType.VarChar, 100), 
                            new SqlParameter("@Validity", SqlDbType.VarChar, 100), new SqlParameter("@Factory", SqlDbType.VarChar, 100), new SqlParameter("@ZhunZi", SqlDbType.VarChar, 100), new SqlParameter("@SumQty", SqlDbType.Int, 4), new SqlParameter("@OneDayQty", SqlDbType.Int, 4), new SqlParameter("@isSendMessage", SqlDbType.Bit, 1), new SqlParameter("@DrugNumber", SqlDbType.VarChar, 100), new SqlParameter("@DrugAbbreviate", SqlDbType.VarChar, 200), new SqlParameter("@extInt", SqlDbType.Int, 4), new SqlParameter("@extInt1", SqlDbType.Int, 4), new SqlParameter("@extstr", SqlDbType.VarChar, 100), new SqlParameter("@extstr1", SqlDbType.VarChar, 200), new SqlParameter("@extstr2", SqlDbType.VarChar, 500), new SqlParameter("@isRx", SqlDbType.VarChar, 10), new SqlParameter("@id", SqlDbType.Int, 4)
                         };
                        cmdParms[0].Value = model.wid;
                        cmdParms[1].Value = model.categoryId;
                        cmdParms[2].Value = model.brandId;
                        cmdParms[3].Value = model.sku;
                        cmdParms[4].Value = model.productName;
                        cmdParms[5].Value = model.shortDesc;
                        cmdParms[6].Value = model.unit;
                        cmdParms[7].Value = model.weight;
                        cmdParms[8].Value = model.description;
                        cmdParms[9].Value = model.seo_title;
                        cmdParms[10].Value = model.seo_keywords;
                        cmdParms[11].Value = model.seo_description;
                        cmdParms[12].Value = model.focusImgUrl;
                        cmdParms[13].Value = model.thumbnailsUrll;
                        cmdParms[14].Value = model.recommended;
                        cmdParms[15].Value = model.latest;
                        cmdParms[0x10].Value = model.hotsale;
                        cmdParms[0x11].Value = model.specialOffer;
                        cmdParms[0x12].Value = model.costPrice;
                        cmdParms[0x13].Value = model.marketPrice;
                        cmdParms[20].Value = model.salePrice;
                        cmdParms[0x15].Value = model.upselling;
                        cmdParms[0x16].Value = model.stock;
                        cmdParms[0x17].Value = model.addDate;
                        cmdParms[0x18].Value = model.vistiCounts;
                        cmdParms[0x19].Value = model.sort_id;
                        cmdParms[0x1a].Value = model.productionDate;
                        cmdParms[0x1b].Value = model.ExpiryEndDate;
                        cmdParms[0x1c].Value = model.updateDate;
                        cmdParms[0x1d].Value = model.catalogId;
                        cmdParms[30].Value = model.shopid;
                        cmdParms[0x1f].Value = model.spec;
                        cmdParms[0x20].Value = model.validity;
                        cmdParms[0x21].Value = model.factory;
                        cmdParms[0x22].Value = model.zhunzi;
                        cmdParms[0x23].Value = model.sumqty;
                        cmdParms[0x24].Value = model.onedayqty;
                        cmdParms[0x25].Value = model.issendmessage;
                        cmdParms[0x26].Value = model.drugnumber;
                        cmdParms[0x27].Value = model.drugabbreviate;
                        cmdParms[40].Value = model.extInt;
                        cmdParms[0x29].Value = model.extInt1;
                        cmdParms[0x2a].Value = model.extstr;
                        cmdParms[0x2b].Value = model.extstr1;
                        cmdParms[0x2c].Value = model.extstr2;
                        cmdParms[0x2d].Value = model.isRx;
                        cmdParms[0x2e].Value = model.id;
                        DbHelperSQL.ExecuteSql(connection, transaction, builder.ToString(), cmdParms);
                        new MxWeiXinPF.DAL.wx_shop_albums().DeleteList(connection, transaction, model.albums, model.id);
                        if (model.albums != null)
                        {
                            foreach (MxWeiXinPF.Model.wx_shop_albums _albums in model.albums)
                            {
                                SqlParameter[] parameterArray2;
                                StringBuilder builder2 = new StringBuilder();
                                if (_albums.id > 0)
                                {
                                    builder2.Append("update  wx_shop_albums set ");
                                    builder2.Append("productId=@productId,");
                                    builder2.Append("thumb_path=@thumb_path,");
                                    builder2.Append("original_path=@original_path,");
                                    builder2.Append("remark=@remark,");
                                    builder2.Append("isdefault=@isdefault");
                                    builder2.Append(" where id=@id");
                                    parameterArray2 = new SqlParameter[] { new SqlParameter("@productId", SqlDbType.Int, 4), new SqlParameter("@thumb_path", SqlDbType.NVarChar, 0xff), new SqlParameter("@original_path", SqlDbType.NVarChar, 0xff), new SqlParameter("@remark", SqlDbType.NVarChar, 500), new SqlParameter("@isdefault", SqlDbType.VarChar, 10), new SqlParameter("@id", SqlDbType.Int, 4) };
                                    parameterArray2[0].Value = _albums.productId;
                                    parameterArray2[1].Value = _albums.thumb_path;
                                    parameterArray2[2].Value = _albums.original_path;
                                    parameterArray2[3].Value = _albums.remark;
                                    parameterArray2[4].Value = _albums.isdefault;
                                    parameterArray2[5].Value = _albums.id;
                                    DbHelperSQL.ExecuteSql(connection, transaction, builder2.ToString(), parameterArray2);
                                }
                                else
                                {
                                    builder2.Append("insert into wx_shop_albums(");
                                    builder2.Append("productId,thumb_path,original_path,remark,isdefault)");
                                    builder2.Append(" values (");
                                    builder2.Append("@productId,@thumb_path,@original_path,@remark,@isdefault)");
                                    parameterArray2 = new SqlParameter[] { new SqlParameter("@productId", SqlDbType.Int, 4), new SqlParameter("@thumb_path", SqlDbType.NVarChar, 0xff), new SqlParameter("@original_path", SqlDbType.NVarChar, 0xff), new SqlParameter("@remark", SqlDbType.NVarChar, 500), new SqlParameter("@isdefault", SqlDbType.VarChar, 10) };
                                    parameterArray2[0].Value = _albums.productId;
                                    parameterArray2[1].Value = _albums.thumb_path;
                                    parameterArray2[2].Value = _albums.original_path;
                                    parameterArray2[3].Value = _albums.remark;
                                    parameterArray2[4].Value = _albums.isdefault;
                                    DbHelperSQL.ExecuteSql(connection, transaction, builder2.ToString(), parameterArray2);
                                }
                            }
                        }
                        StringBuilder builder3 = new StringBuilder();
                        builder3.Append("delete from wx_shop_productAttr_value where productId=@productId;");
                        builder3.Append("delete from wx_shop_sku where productId=productId");
                        SqlParameter[] parameterArray3 = new SqlParameter[] { new SqlParameter("@productId", SqlDbType.Int, 4) };
                        parameterArray3[0].Value = model.id;
                        DbHelperSQL.ExecuteSql(connection, transaction, builder3.ToString(), parameterArray3);
                        if (model.attrs != null)
                        {
                            foreach (MxWeiXinPF.Model.wx_shop_productAttr_value _value in model.attrs)
                            {
                                StringBuilder builder4 = new StringBuilder();
                                builder4.Append("insert into  wx_shop_productAttr_value(");
                                builder4.Append("productId,attributeId,paValue)");
                                builder4.Append(" values (");
                                builder4.Append("@productId,@attributeId,@paValue)");
                                SqlParameter[] parameterArray4 = new SqlParameter[] { new SqlParameter("@productId", SqlDbType.Int, 4), new SqlParameter("@attributeId", SqlDbType.Int, 4), new SqlParameter("@paValue", SqlDbType.NVarChar, 300) };
                                parameterArray4[0].Value = model.id;
                                parameterArray4[1].Value = _value.attributeId;
                                parameterArray4[2].Value = _value.paValue;
                                DbHelperSQL.ExecuteSql(connection, transaction, builder4.ToString(), parameterArray4);
                            }
                        }
                        if (model.skulist != null)
                        {
                            foreach (MxWeiXinPF.Model.wx_shop_sku _sku in model.skulist)
                            {
                                StringBuilder builder5 = new StringBuilder();
                                builder5.Append("insert into  wx_shop_sku(");
                                builder5.Append("productId,attributeId,attributeValue,price)");
                                builder5.Append(" values (");
                                builder5.Append("@productId,@attributeId,@attributeValue,@price)");
                                SqlParameter[] parameterArray5 = new SqlParameter[] { new SqlParameter("@productId", SqlDbType.Int, 4), new SqlParameter("@attributeId", SqlDbType.Int, 4), new SqlParameter("@attributeValue", SqlDbType.NVarChar, 300), new SqlParameter("@price", SqlDbType.Float, 10) };
                                parameterArray5[0].Value = model.id;
                                parameterArray5[1].Value = _sku.attributeId;
                                parameterArray5[2].Value = _sku.attributeValue;
                                parameterArray5[3].Value = _sku.price;
                                DbHelperSQL.ExecuteSql(connection, transaction, builder5.ToString(), parameterArray5);
                            }
                        }
                        transaction.Commit();
                    }
                    catch (Exception)
                    {
                        transaction.Rollback();
                        return false;
                    }
                }
            }
            return true;
        }

        public void UpdateField(int id, string strValue)
        {
            StringBuilder builder = new StringBuilder();
            builder.Append("update wx_shop_product set " + strValue);
            builder.Append(" where id=" + id);
            DbHelperSQL.ExecuteSql(builder.ToString());
        }
    }
}

